package com.example.demo.domain.product.dto;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.Instant;

import com.example.demo.domain.product.entity.Product;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ProductDto implements Serializable {

	private static final long serialVersionUID = 1L;

	private String id;

	private String name;

	private String description;

	private BigDecimal price;

	private Instant createTime;

	public static ProductDto from(Product product) {
		return ProductDto.builder()
				.id(product.getId())
				.name(product.getName())
				.description(product.getDescription())
				.price(product.getPrice())
				.createTime(product.getCreateTime())
				.build();
	}

}
